package com.leoman.user.dao;

import com.leoman.common.dao.IBaseJpaRepository;
import com.leoman.systemsetting.entity.LimitWords;
import com.leoman.user.entity.UserInfo;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * 用户信息dao
 * Created by 涂奕恒 on 2016/6/12.
 */
public interface UserInfoDao extends IBaseJpaRepository<UserInfo> {

    @Query("select a from UserInfo a where a.userLogin.id = ?1")
    UserInfo findOneByUserId(Long userId);

    @Query("select a from UserInfo a where a.isCreator <> 0")
    List<UserInfo> findByStatus();

    @Query("select a from UserInfo a where a.creator.id = ?1")
    UserInfo findOneByCreatorId(Long creatorId);

    @Query("select a from UserInfo a where a.weixin = ?1")
    List<UserInfo> findOneByWeixin(String weixin);

    @Query("select a from UserInfo a where a.weibo = ?1")
    List<UserInfo> findOneByWeibo(String weibo);

    @Query("select a from UserInfo a where a.qq = ?1")
    List<UserInfo> findOneByQQ(String qq);

    @Query("select a from UserInfo a where a.mobile = ?1")
    UserInfo findOneByMobile(String mobile);

    @Query("select a from UserInfo a where a.nickname = ?1")
    UserInfo findOneByNickname(String nickname);

    @Query("select a from UserInfo a where a.createDate > ?1 and a.isCreator = 0")
    List<UserInfo> findListNew(Long oldDate);

    @Query("select a from UserInfo a where a.isCreator = ?1 and a.status <> 1")
    List<UserInfo> iFindListByIsCreator(Integer isCreator);

    @Query("select a from LimitWords a")
    List<LimitWords> findLimitList();

    @Query("select a from UserInfo a where (a.isCreator <> 0 or a.type = 1) and a.status = 0")
    List<UserInfo> findList();
}
